package com.llf.usercenter.once;

import com.alibaba.excel.EasyExcel;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 导入星球用户到数据库
 */
public class ImportXingQiuUser {

    public static void main(String[] args) {
        String fileName = "E:\\idea\\user-center\\src\\main\\resources\\testExcel.xlsx";
        List<XingQiuUserInfo> userInfoList= EasyExcel.read(fileName).head(XingQiuUserInfo.class).sheet().doReadSync();
        System.out.println("总数 = " + userInfoList.size());
        //按用户昵称相同进行分组
        Map<String, List<XingQiuUserInfo>> listMap = userInfoList
                .stream()
                .filter(userInfo -> StringUtils.isNotEmpty(userInfo.getUsername()))
                .collect(Collectors.groupingBy(XingQiuUserInfo::getUsername));
        System.out.println("不重复昵称数" + listMap.keySet().size());
    }
}
